<?php
namespace Home\Controller;
class XiangController extends HomeController {
	public function index(){
		$id=I('get.id');
		$mprice=I('get.id');
		$goods=M('shop')->where(array('id'=>$id))->find();
		$cate=get_parent_category($goods['cate']);
		$attr=M('shopatt')->where(array('pid'=>$id))->select();
		$att=M('att')->where(array('gid'=>$id))->select();
		$price=M('price')->where(array('pid'=>$id))->select();
		//$re=M('shop')->where()
		foreach ($price as $v) {
			$prices['mprice'][]=$v['mprice'];
			$prices['sprice'][]=$v['sprice'];
		}
		$goods['mprice']=min($prices['mprice']);
		$goods['sprice']=min($prices['sprice']);
		foreach ($attr as $k=>$v) {
			foreach ($att as $a) {
				if ($a['pid']==$v['id']) {
					$attr[$k][val][]=$a;
				}
			}
		}
     	$this->assign('goods',$goods);
		$this->assign('attr',$attr);
		$this->assign('cate',$cate);
		$this->display();
	}
	public function price(){
		$map['pid'] = I('post.gid');
		$map['ar'] = implode(',', I('post.attre'));
		$res = M('price')->where($map)->find();
		// var_dump($res);
		$this->ajaxReturn($res);
	}
}